增加调试日志显示

chengzhenyu 7 年之前
父节点
当前提交
0e7d071bc9

+ 12 - 1
app/src/main/java/ai/pai/lensman/session/SessionActivity.java

@@ -38,6 +38,7 @@ public class SessionActivity extends BaseActivity implements SessionContract.Vie
38 38
     @BindView(R.id.title_bar_middle_txt) TextView titleTextView;
39 39
     @BindView(R.id.recycler_view_photos) RecyclerView photosRecyclerView;
40 40
     @BindView(R.id.iv_scan)              ImageView qrcodeScanBtn;
41
+    @BindView(R.id.tv_camera_status)     TextView cameraStatusTextView;
41 42
 
42 43
     private PhotoRecyclerAdapter adapter;
43 44
     private  SessionBean sessionBean;
@@ -80,9 +81,9 @@ public class SessionActivity extends BaseActivity implements SessionContract.Vie
80 81
         sessionBean =(SessionBean)getIntent().getSerializableExtra("session");
81 82
         if(BuildConfig.isTestMode){
82 83
             sessionBean.sessionId="test";
84
+            cameraStatusTextView.setVisibility(View.VISIBLE);
83 85
         }
84 86
         presenter = new SessionPresenter(sessionBean,this);
85
-
86 87
         titleTextView.setText(getString(R.string.scene,sessionBean.sessionSeq));
87 88
         adapter = new PhotoRecyclerAdapter(this);
88 89
 
@@ -215,6 +216,16 @@ public class SessionActivity extends BaseActivity implements SessionContract.Vie
215 216
     }
216 217
 
217 218
     @Override
219
+    public void refreshCameraStatus(final String status) {
220
+        cameraStatusTextView.post(new Runnable() {
221
+            @Override
222
+            public void run() {
223
+                cameraStatusTextView.setText(status);
224
+            }
225
+        });
226
+    }
227
+
228
+    @Override
218 229
     protected void onActivityResult(int requestCode, int resultCode, Intent data) {
219 230
         super.onActivityResult(requestCode,resultCode,data);
220 231
         if (resultCode == Activity.RESULT_OK) {

+ 1 - 0
app/src/main/java/ai/pai/lensman/session/SessionContract.java

@@ -18,6 +18,7 @@ public class SessionContract {
18 18
         void showToast(String toast);
19 19
         void refreshUploadTimeHint();
20 20
         void addPhotos(ArrayList<PhotoBean> photoList);
21
+        void refreshCameraStatus(String status);
21 22
     }
22 23
 
23 24
     interface Presenter extends BasePresenter{

+ 6 - 1
app/src/main/java/ai/pai/lensman/session/SessionInteractor.java

@@ -44,6 +44,7 @@ public class SessionInteractor implements Callback{
44 44
     public boolean handleMessage(Message message) {
45 45
         if(message.what==MSG_CAMERA_INIT_EVENT){
46 46
             int result = CameraJNIInterface.getInstance().java_mygpcamerainit();
47
+            listener.onCameraStatusChanged("mygpcamerainit return "+result);
47 48
             if(result>=0){
48 49
                 listener.onSessionStartSuccess(sessionBean.sessionId);
49 50
                 isWorking = true;
@@ -60,6 +61,7 @@ public class SessionInteractor implements Callback{
60 61
         void onSessionStartError(String session);
61 62
         void onSessionPhotoCaptured(PhotoBean bean);
62 63
         void onSessionEnd(String session);
64
+        void onCameraStatusChanged(String status);
63 65
     }
64 66
 
65 67
     public void startSession(){
@@ -69,6 +71,7 @@ public class SessionInteractor implements Callback{
69 71
        new File(sessionWorkingDirPath).mkdirs();
70 72
 
71 73
         int result = CameraJNIInterface.getInstance().java_mygpcamerainit();
74
+        listener.onCameraStatusChanged("mygpcamerainit return "+result);
72 75
         if(result>=0){
73 76
             LogHelper.d("czy","mygpcamerainit init success="+result);
74 77
             listener.onSessionStartSuccess(sessionBean.sessionId);
@@ -114,6 +117,7 @@ public class SessionInteractor implements Callback{
114 117
 
115 118
         isLastQueryReturned = false;
116 119
         String eventMsg = CameraJNIInterface.getInstance().java_mygpcamerawaitforevent(sessionWorkingDirPath);
120
+        listener.onCameraStatusChanged("mygpcamerawaitforevent return "+eventMsg);
117 121
         LogHelper.d("czy","mygpcamerawaitforevent return result = "+eventMsg);
118 122
         if(eventMsg!=null && eventMsg.length()>0){
119 123
             if(MSG_TYPE_NOT_INIT.equalsIgnoreCase(eventMsg)||MSG_TYPE_CAMERA_ERROR.equalsIgnoreCase(eventMsg)){
@@ -153,7 +157,8 @@ public class SessionInteractor implements Callback{
153 157
             photoCaptureTimer.cancel();
154 158
             photoCaptureTimer = null;
155 159
         }
156
-        CameraJNIInterface.getInstance().java_mygpcameraexit();
160
+        int result = CameraJNIInterface.getInstance().java_mygpcameraexit();
161
+        listener.onCameraStatusChanged("mygpcameraexit return "+result);
157 162
         listener.onSessionEnd(sessionBean.sessionId);
158 163
         if(cameraInitHandler!=null){
159 164
             cameraInitHandler.removeCallbacksAndMessages(null);

+ 5 - 0
app/src/main/java/ai/pai/lensman/session/SessionPresenter.java

@@ -107,6 +107,11 @@ public class SessionPresenter implements SessionContract.Presenter, SessionInter
107 107
     }
108 108
 
109 109
     @Override
110
+    public void onCameraStatusChanged(String status) {
111
+        sessionView.refreshCameraStatus(status);
112
+    }
113
+
114
+    @Override
110 115
     public void swipeToDeletePhoto(int index) {
111 116
         if(index<0 || index>= photoList.size()){
112 117
             return;

+ 10 - 0
app/src/main/res/layout/activity_session.xml

@@ -81,6 +81,16 @@
81 81
             android:layout_width="match_parent"
82 82
             android:layout_height="match_parent" />
83 83
 
84
+        <TextView
85
+            android:id="@+id/tv_camera_status"
86
+            android:layout_width="match_parent"
87
+            android:layout_height="48dp"
88
+            android:textSize="16sp"
89
+            android:textColor="@color/dark_grey"
90
+            android:gravity="center_vertical"
91
+            android:background="@color/white"
92
+            android:visibility="gone"/>
93
+
84 94
         <ImageButton
85 95
             android:id="@+id/btn_session_complete"
86 96
             android:layout_width="68dp"